home *** CD-ROM | disk | FTP | other *** search
/ Disc to the Future 2 / Disc to the Future Part II Programmer's Reference (Wayzata Technology)(6013)(1992).bin / MAC / THINKC / TCL1 / __MANDEL / MANDELBR / CMANDELT.C < prev    next >
Text File  |  1992-03-25  |  1KB  |  55 lines

  1. //    CMandelTextFile.c
  2.  
  3. #include "CMandelDoc.h"
  4. #include "CMandelTextFile.h"
  5.  
  6. char *CMandelTextFile::cFormats[] = {
  7.     "origin (a, b): %Lg, %Lg\n",
  8.     "view rect (width, height): %d, %d\n",
  9.     "view depth: %d\n",
  10.     "scale: %Lg\n",
  11.     "dwell limit: %d\n"
  12.     };
  13.     
  14. void
  15. CMandelTextFile::IMandelTextFile(CMandelDoc *theMandelDoc)
  16. {
  17.     CStdioFile::IStdioFile();
  18.     
  19.     itsMandelDoc = theMandelDoc;
  20. }
  21.  
  22. void
  23. CMandelTextFile::WriteAll(Handle theDataH)
  24. {
  25.     TMandelInfo        aInfoRec;
  26.     
  27.     itsMandelDoc->GetMandelInfo(&aInfoRec);
  28.     
  29.     printf(cFormats[0], aInfoRec.fHOrigin, aInfoRec.fVOrigin);
  30.     printf(cFormats[1], aInfoRec.fWidth, aInfoRec.fHeight);
  31.     printf(cFormats[2], 32);
  32.     printf(cFormats[3], aInfoRec.fScale);
  33.     printf(cFormats[4], aInfoRec.fMaxDwell);
  34. }
  35.  
  36. Handle
  37. CMandelTextFile::ReadAll(void)
  38. {
  39.     TMandelInfo        aInfoRec;
  40.     int                aCount = 0;
  41.     
  42.     aCount += scanf(cFormats[0], &aInfoRec.fHOrigin, &aInfoRec.fVOrigin);
  43.     aCount += scanf(cFormats[1], &aInfoRec.fWidth, &aInfoRec.fHeight);
  44.     aCount += scanf(cFormats[2], &aInfoRec.fDepth);
  45.     aCount += scanf(cFormats[3], &aInfoRec.fScale);
  46.     aCount += scanf(cFormats[4], &aInfoRec.fMaxDwell);
  47.     
  48.     if (aCount != 7)
  49.         Failure(readErr, 0);
  50.     
  51.     itsMandelDoc->SetMandelInfo(&aInfoRec);
  52.     itsMandelDoc->DoGenerate();
  53.     return NULL;
  54. }
  55.